package {
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import views.CalendarView;
	import flash.events.Event;
	import flash.display.Sprite;

	/**
	 * @author Alexander Slavshik
	 * created 4.3.2011
	 */
	//[SWF(backgroundColor="#FFFFFF", frameRate="31", width="200", height="100")]
	
	public class Calendar extends Sprite {
		
		public static var deadLine : Date;
		private var _view : CalendarView;
		
		public static var instance:Calendar;
		
		public function Calendar() {
			if(stage){
				onAddedToStage();
			}else{
				addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			}
		}

		private function onAddedToStage(event : Event = null) : void {
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			stage.scaleMode = 'noScale';
			
			instance = this;

			_view = new CalendarView();
			
			addChild(_view);
			
			var deadlineStr:String = loaderInfo.parameters.hasOwnProperty("deadline") ? loaderInfo.parameters.deadline : "03/16/2011";
			deadLine = new Date(deadlineStr);
			
			_view.start(deadLine);
		}
	}
}
